<?php
namespace app\tools\controller;
use app\tools\logic\ApiLogic;
use app\tools\logic\UserLogic;

class User extends Base{
	//获取管理员列表
	function getList(){
		$data = UserLogic::getList();
		return ApiLogic::return(0,'',$data);
	}
	//获取详情
	function getInfo(){
		$info = UserLogic::getInfo();
		return ApiLogic::return(0,'',$info);
	}
	//保存
	function save(){
		$rs = UserLogic::save();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}
	//新增
	function add(){
		$rs = UserLogic::add();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}
	//获取当前登录用户的信息
    function getMyInfo(){
    	$token = $this->request->header('token');
    	$info = UserLogic::getMyInfo($token);
    	return ApiLogic::return(0,'',$info);
    }

    //删除
	function delete(){
		$rs = UserLogic::delete();
		if($rs){
			return ApiLogic::return($rs);
		}else{
			return ApiLogic::return(0);
		}
	}

	function getMenu(){
		$token = $this->request->header('token');
		$rs = UserLogic::getMenu($token);
		return ApiLogic::return(0,'',$rs);
	}
}
